package com.jcode.skeleton.model;


/**
 * 
 * @Desc
 * 
 * @Author dreajay
 * @DateTime 2015-9-28 下午08:33:19
 * 
 */
public class ResponsePacket extends MapExtensible {

	private static final long serialVersionUID = 114900770400552987L;

	/** 成功响应码 */
	public static final String SUCCESS_CODE = "0";

	private String errCode = SUCCESS_CODE;

	private String errMsg;

	/**
	 * 响应模型实体
	 */
	private Object result;

	public ResponsePacket() {
	}

	public ResponsePacket(Object result) {
		this.result = result;
	}

	public ResponsePacket(String errCode, String errMsg) {
		this.errCode = errCode;
		this.errMsg = errMsg;
	}

	public ResponsePacket(String errCode, String errMsg, Object result) {
		this.errCode = errCode;
		this.errMsg = errMsg;
		this.result = result;
	}

	/**
	 * 获取响应码
	 * 
	 * @return 响应码
	 */
	public String getErrCode() {
		return errCode;
	}

	/**
	 * 设置响应码
	 * 
	 * @param errCode
	 *            响应码
	 */
	public void setErrCode(String errCode) {
		this.errCode = errCode;
	}

	/**
	 * 获取响应信息
	 * 
	 * @return 响应信息
	 */
	public String getErrMsg() {
		return errMsg;
	}

	/**
	 * 设置响应信息
	 * 
	 * @param retMsg
	 *            响应信息
	 */
	public void setErrMsg(String errMsg) {
		this.errMsg = errMsg;
	}

	/**
	 * 获取结果
	 * 
	 * @return
	 */
	@SuppressWarnings({ "unchecked" })
	public <T> T getResult() {
		return (T) result;
	}

	/**
	 * 设置结果
	 * 
	 * @param result
	 */
	public void setResult(Object result) {
		this.result = result;
	}

	public static ResponsePacket getSuccessResponsePacket() {
		return new ResponsePacket();
	}

	public static ResponsePacket getResponsePacket(Object result) {
		return new ResponsePacket(result);
	}

	public static ResponsePacket getResponsePacket(String errCode, String errMsg) {
		return new ResponsePacket(errCode, errMsg);
	}

	public static ResponsePacket getResponsePacket(String errCode, String errMsg, Object result) {
		return new ResponsePacket(errCode, errMsg, result);
	}

}
